from tqdm.notebook import trange
def make_shots(figname, r = 16,
B_tf = .1,
B_sf = .05,
B_theta = .1,
theta = np.pi*(3 - np.sqrt(5)), # https://en.wikipedia.org/wiki/Golden_angle
T_movie = T_movie,
slope = 2.,
fps = fps,
cache_path='/tmp',
W=W, H=H):
z_pure = envelope_alpha(fx, fy, ft, tf_0=tf_0, B_tf=B_tf, B_sf=B_sf, theta=theta, B_theta=B_theta)
movie_pure = mc.rectif(mc.random_cloud(z_pure))
movie_pure_ = np.zeros((movie_pure.shape[0], movie_pure.shape[1]+1, movie_pure.shape[2]))
movie_pure_[:, :-1, :] = movie_pure
movie_pure_[:, -1, :] = movie_pure[:, 0, :]
movie_pure = movie_pure_
# get coordinates of boxes in the mesh :
phi = np.linspace(0, 2*np.pi, movie_pure.shape[1])
r = np.linspace(0, 1, movie_pure.shape[0])
Phi, R = np.meshgrid(phi, r)
movie_pure_bw = np.tanh(slope*movie_pure)
import matplotlib
ppi = 72.27 # (constant) definition of the ppi = points per inch
inches_per_pt = 1.0/ppi # Convert pt to inches
#inches_per_cm = 1./2.54
figwidth = W*inches_per_pt # width in inches
subplotpars = matplotlib.figure.SubplotParams(left=0., right=1., bottom=0., top=1., wspace=0., hspace=0.,)
fnames = []
figname_ = figname.split('/')[-1]
for t in trange(movie_pure.shape[2]):
fname = f'{cache_path}/{figname_}_{t}.png'
fig, ax = plt.subplots(1, 1, figsize=(fig_width, fig_width), subplot_kw=dict(polar=True))
m = ax.pcolormesh(Phi, R, movie_pure[:, :, t], shading='gouraud', vmin=movie_pure.min(), vmax=movie_pure.max(),
edgecolors='none', cmap="Spectral")
ax.set_xticks([])
ax.set_yticks([])
fig.savefig(fname, dpi=ppi)
fnames.append(fname)
make_mp4(figname, fnames, fps=fps)
gifname = make_gif(figname.replace('.mp4', '.gif'), fnames, fps=fps)
for fname in fnames: os.remove(fname)
return figname # returns filename
figname = os.path.join(mc.figpath, 'retino_alpha.mp4')
if True: #not os.path.isfile(figname):
figname = make_shots(figname)